home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Mixed Mode Maddness / Emulator / Source / stack.c < prev   
Encoding:
C/C++ Source or Header  |  2000-06-24  |  950 b   |  50 lines

  1. #include "6502.h"
  2. #include "global.h"
  3. #include "stack.h"
  4.  
  5. // Note the stack lives from 0x01FF - 0x0100
  6.  
  7. //////////////////////////////////////////////
  8. //
  9. //    PushByte        Push Byte on Stack
  10. //
  11. //////////////////////////////////////////////
  12. void PushByte(UInt8 theByte)
  13. {
  14.     gStack[sp--] = theByte;
  15. }
  16.  
  17. //////////////////////////////////////////////
  18. //
  19. //    PushWord        Push 2 Bytes on Stack
  20. //
  21. //
  22. //////////////////////////////////////////////
  23. void PushWord(UInt16 theWord)
  24. {
  25.     PushByte(theWord & 0xFF);
  26.     PushByte(theWord >> 8);
  27. }
  28.  
  29. //////////////////////////////////////////////
  30. //
  31. //    PopByte        Pop Byte from Stack
  32. //
  33. //////////////////////////////////////////////
  34. UInt8 PopByte(void)
  35. {
  36.     return gStack[++sp];
  37. }
  38.  
  39. //////////////////////////////////////////////
  40. //
  41. //    PopWord        Pop Word from Stack
  42. //
  43. //////////////////////////////////////////////
  44. UInt16 PopWord(void)
  45. {
  46.     UInt16 theWord = (((UInt16)(gStack[++sp])) << 8);
  47.     theWord |= gStack[++sp];
  48.     return theWord;
  49. }
  50.